home *** CD-ROM | disk | FTP | other *** search
- /****************************************************************************/
- /* */
- /* Application: QuickDraw™ FX */
- /* */
- /* Description: */
- /* */
- /* File: menu.c */
- /* */
- /* Files: FX.π */
- /* FX.π.rsrc */
- /* FX.h */
- /* events.c */
- /* main.c */
- /* menu.c */
- /* */
- /* Programmer: Edgar Lee */
- /* Organization: Apple Computer, Inc. ©1992 */
- /* Department: Developer Technical Support, DTS */
- /* Language: C (Think C version 5.0.2) */
- /* Date Created: 5-26-92 */
- /* */
- /****************************************************************************/
-
- #include "FX.h"
-
- enum {
- appleID = 128,
- fileID = 129,
- exID = 130,
- srcID = 131
- };
-
- enum {
- quitItem = 1
- };
-
- #define WWIDTH 420
- #define WHEIGHT 200
-
- #define WLEFT (((screenBits.bounds.right - screenBits.bounds.left) - WWIDTH) / 2)
- #define WTOP (((screenBits.bounds.bottom - screenBits.bounds.top) - WHEIGHT) / 2)
-
- void doAboutBox();
- void drawMyString();
-
- void setUpMenus()
- {
- Handle menuHandle;
-
- if ((menuHandle = GetNewMBar( 128 )) == nil)
- ExitToShell();
-
- SetMenuBar( menuHandle );
- AddResMenu( GetMenu( appleID ), 'DRVR' );
-
- DrawMenuBar();
- ReleaseResource( menuHandle );
- }
-
- void adjustMenus()
- {
- int i;
-
- EnableItem( GetMHandle( fileID ), quitItem );
-
- for (i = 1; i <= pixelAverageID; i++)
- setMenuItem( GetMHandle( exID ), i, (i == gCurrentExample / 10) );
-
- setMenuItem( GetMHandle( exID ), customID + 1, (customID == gCurrentExample / 10) );
- }
-
- void setMenuItem( menu, itemNum, enabled )
- MenuHandle menu;
- int itemNum;
- Boolean enabled;
- {
- if (enabled)
- CheckItem( menu, itemNum, true );
- else
- CheckItem( menu, itemNum, false );
- }
-
- void handleMenu( mSelect )
- long mSelect;
- {
- int menuID = HiWord( mSelect );
- int menuItem = LoWord( mSelect );
- GrafPtr savePort;
- Str255 name;
- long ticks;
-
- switch (menuID)
- {
- case appleID:
- if (menuItem == 1)
- doAboutBox();
- else
- {
- GetPort( &savePort );
- GetItem( GetMenu( appleID ), menuItem, name );
- OpenDeskAcc( name );
- SetPort( savePort );
- }
- break;
-
- case fileID:
- if (menuItem)
- ExitToShell();
- break;
-
- case exID:
- if (menuItem == 10)
- menuItem--;
-
- if (menuItem == gCurrentExample / 10)
- break;
-
- if (menuItem == 9)
- resetItems();
-
- gCurrentExample = (menuItem * 10) + 1;
- drawExampleName();
- drawSourceImage();
-
- ticks = drawFXImage();
- drawTime( ticks );
- drawAllItems();
- break;
-
- case srcID:
- createOffscreen( menuItem );
- drawSourceImage();
-
- ticks = drawFXImage();
- drawTime( ticks );
- break;
- }
-
- HiliteMenu( 0 );
- }
-
- void doAboutBox()
- {
- int col, row;
- int width, height;
- WindowPtr window;
- CIconHandle cicn;
- Rect rect;
- RGBColor color;
-
- cicn = GetCIcon( 128 );
- HPurge( cicn );
-
- SetRect( &rect, WLEFT, WTOP, WLEFT + WWIDTH, WTOP + WHEIGHT );
- window = NewCWindow( 0L, &rect, "\p", true, plainDBox, (WindowPtr)-1L, false, 0L );
- SetPort( window );
-
- TextFont( geneva );
- TextMode( srcOr );
-
- color.red = color.green = color.blue = 8700;
- RGBForeColor( &color );
-
- rect = window->portRect;
- InsetRect( &rect, 1, 1 );
- PaintRect( &rect );
-
- width = 32 * 6;
- height = width;
-
- SetRect( &rect, 3, 3, width + 3, height + 3 );
- PlotCIcon( &rect, cicn );
-
- ForeColor( blackColor );
-
- for (row = 6; row < height; row += 6)
- {
- MoveTo( rect.left, rect.top + row );
- LineTo( rect.left + width, rect.top + row );
- }
-
- for (col = 6; col < width; col += 6)
- {
- MoveTo( rect.left + col, rect.top );
- LineTo( rect.left + col, rect.top + height );
- }
-
- col = width + 15;
- row = 35;
-
- TextFont( times );
- TextSize( 36 );
-
- color.blue = 0xffff;
- color.red = color.green = 0;
- RGBForeColor( &color );
- drawMyString( col, &row, 30, "\pQuickDraw™" );
-
- color.blue = 0x9fff;
- RGBForeColor( &color );
- drawMyString( col + 45, &row, -5, "\pFX" );
-
- TextFont( geneva );
- TextSize( 9 );
- ForeColor( whiteColor );
-
- col += 10;
-
- drawMyString( col + 115, &row, 25, "\pVersion 1.0" );
- drawMyString( col, &row, 20, "\pBrought to you by Edgar Lee." );
-
- drawMyString( col, &row, 13, "\pFor any suggestions or comments," );
- drawMyString( col, &row, 13, "\pplease write to edgar@apple.com" );
- drawMyString( col, &row, 20, "\por appleLink EDGAR." );
-
- drawMyString( col, &row, 15, "\p© 1992 Apple Computer, Inc." );
- drawMyString( col, &row, 25, "\pAll rights reserved." );
-
- TextFont( times );
- TextSize( 36 );
-
- color.green = 0x8fff;
- color.red = color.blue = 0;
- RGBForeColor( &color );
- drawMyString( col + 125, &row, 0, "\pDTS" );
-
- while (!Button());
-
- DisposeWindow( window );
- }
-
- void drawMyString( col, row, increment, string )
- int col, *row, increment;
- Str255 string;
- {
- RGBColor color;
-
- GetForeColor( &color );
-
- ForeColor( blackColor );
- MoveTo( col + 2, *row + 2 );
- DrawString( string );
-
- RGBForeColor( &color );
- MoveTo( col, *row );
- DrawString( string );
-
- *row += increment;
- }